/*
 * Copyright 2002-2005 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package lib.jsonrpc;


import java.util.*;

/**
 * The Class AccountServiceImpl. service side remote service implementation.
 * 
 * usually extends from BasicRPCService.
 * 
 * 
 * @author jay liu
 * @since 07.10.2010
 */
public class AccountServiceImpl extends BasicRPCService implements AccountService {

	
	

	/* (non-Javadoc)
	 * @see lib.jsonrpc.AccountService#getAccount(java.lang.String)
	 */
	@Override
	public Account getAccount(String name) {
		Account jay = new Account();
		jay.setName("jay liu");
		jay.setAge(35);
		jay.setBalance(1000.00);
		jay.setBirthday(Calendar.getInstance().getTime());
		jay.setId(1L);
		jay.setNickName("jay");
		return jay;
	}

	/* (non-Javadoc)
	 * @see lib.jsonrpc.AccountService#getAge(java.lang.String)
	 */
	@Override
	public Integer getAge(String name) {
		System.out.println("name:" + name);
		return 35;
	}

	/* (non-Javadoc)
	 * @see lib.jsonrpc.AccountService#getBalance(lib.jsonrpc.Account)
	 */
	@Override
	public Double getBalance(Account account) {
	
		System.out.println(account);
		return 1000.00;
	}

	/* (non-Javadoc)
	 * @see lib.jsonrpc.AccountService#getId(java.lang.String)
	 */
	@Override
	public Long getId(String name) {
		System.out.println("name:" + name);
		return 1L;
	}

	/* (non-Javadoc)
	 * @see lib.jsonrpc.AccountService#getName(java.lang.Long)
	 */
	@Override
	public String getName(Long id) {
		System.out.println("id:" + id);
		return "jay liu";
	}
	
	/* (non-Javadoc)
	 * @see lib.jsonrpc.AccountService#getAccounts()
	 */
	public Collection<Account> getAccounts(){
		List<Account> result = new ArrayList<Account>();
		
		Account jay = new Account();
		jay.setName("jay liu");
		jay.setAge(35);
		jay.setBalance(1000.00);
		jay.setBirthday(Calendar.getInstance().getTime());
		jay.setId(1L);
		jay.setNickName("jay");
		
		result.add(jay);

		Account jasmine = new Account();
		jasmine.setName("jasmine");
		jasmine.setAge(34);
		jasmine.setBalance(1000.00);
		jasmine.setBirthday(Calendar.getInstance().getTime());
		jasmine.setId(1L);
		jasmine.setNickName("jasmine");

		result.add(jasmine);
		
		return result;
		
	}

	
}
